<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目收益列表')"/>
    <th:block th:include="include :: daterangepicker-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>日期：</label>
                            <input type="text" name="dateInfo" id="dateInfo" autocomplete="off"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="profit:profit:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary" onclick="profitChart();">
                收益折线图
            </a>
            <!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="profit:profit:edit">-->
            <!--                    <i class="fa fa-edit"></i> 修改-->
            <!--                </a>-->
            <!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="profit:profit:remove">-->
            <!--                    <i class="fa fa-remove"></i> 删除-->
            <!--                </a>-->
            <!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="profit:profit:export">-->
            <!--                    <i class="fa fa-download"></i> 导出-->
            <!--                </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: daterangepicker-js"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('profit:profit:edit')}]];
    var removeFlag = [[${@permission.hasPermi('profit:profit:remove')}]];
    var prefix = ctx + "profit/profit";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "项目收益",
            columns: [
                //     {
                //     checkbox: true
                // },
                // {
                //     field: 'id',
                //     title: '',
                //     visible: false
                // },
                {
                    field: 'dateInfo',
                    title: '日期'
                },
                // {
                //     field: 'dcProfit',
                //     title: '贷超'
                // },
                // {
                //     field: 'zdProfit',
                //     title: '助贷'
                // },
                // {
                //     field: 'zdNumber',
                //     title: '表单量'
                // },
                // {
                //     field: 'zdAvgProfit',
                //     title: '表单平均收益'
                // },

                {
                    field: 'prodUvProfit',
                    title: '产品uv收益'
                },
                {
                    field: 'prodUnionProfit',
                    title: '联登收益'
                },
                {
                    field: 'pushFormProfit',
                    title: '表单收益'
                },
                {
                    field: 'pushSpecialProfit',
                    title: '推送收益'
                }, {
                    field: 'riskCostAmount',
                    title: '风控成本'
                }, {
                    field: 'sourceCostAmount',
                    title: '来源成本'
                }, {
                    field: 'channelUvCostAmount',
                    title: 'uv成本'
                }, {
                    field: 'channelRegisterCostAmount',
                    title: '注册成本'
                },
                {
                    field: '',
                    title: '创建',
                    formatter: function (value, row, index) {
                        var creatorId = row.creatorId || "";
                        var creatorName = row.creatorName || "";
                        var result = "-";
                        if (creatorName !== "" && creatorId !== "") {
                            result = creatorName + '(' + creatorId + ')';
                        }
                        return result;
                    }
                },
                {
                    field: '',
                    title: '更新',
                    formatter: function (value, row, index) {
                        var updatorId = row.updatorId || "";
                        var updatorName = row.updatorName || "";
                        var result = "-";
                        if (updatorName !== "" && updatorId !== "") {
                            result = updatorName + '(' + updatorId + ')';
                        }
                        return result;
                    }
                },
                // {
                //     field: 'totalProfit',
                //     title: '总收益'
                // },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.dateInfo != '' && row.dateInfo != undefined) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        }
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

        $('#dateInfo').daterangepicker({
            autoUpdateInput: false,
            "locale": {
                "direction": "ltr",
                "format": "YYYY-MM-DD",
                "separator": " ~ ",
                "applyLabel": "确定",
                "cancelLabel": "取消",
                "daysOfWeek": ["七", "一", "二", "三", "四", "五", "六"],
                "monthNames": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
            },
        });
        $('#dateInfo').on('apply.daterangepicker', function (ev, picker) {
            $(this).val(picker.startDate.format('YYYY-MM-DD') + ' ~ ' + picker.endDate.format('YYYY-MM-DD'));
        });
        $('#dateInfo').on('cancel.daterangepicker', function (ev, picker) {
            $(this).val('');
        });

    });

    function profitChart() {
        var url = prefix + '/chart';
        $.modal.openTab("收益折线图", url);
    }
</script>
</body>
</html>